const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const questionFavValidate = require('@/middlewares/validateMiddlewares/questionFavValidate')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')
const questionFavController = require('@/controller/questionFavController')

const router = new Router()

/**
 * 获取题目收藏列表
 */
router.get(
  '/list',
  verifyToken(),
  questionFavValidate.listQuestionFavValidate,
  questionFavController.listQuestionFav
)

/**
 * 获取题目试卷列表
 */
router.get(
  '/paperList',
  verifyToken(),
  questionFavValidate.listPaperFavValidate,
  questionFavController.listFavPaper
)

/**
 * 获取小于当前用户的题目收藏列表
 */
router.get(
  '/auth/list',
  verifyToken(),
  questionFavValidate.listQuestionFavValidate,
  questionFavController.listQuestionFav
)

/**
 * 创建题目收藏列表
 */
router.post(
  '/create',
  verifyToken(),
  questionFavValidate.createQuestionFavValidate,
  questionFavController.createQuestionFav
)

/**
 * 删除题目收藏列表
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  questionFavValidate.delQuestionFavsValidate,
  questionFavController.delQuestionFavs
)

/**
 * 题目收藏排序
 */
router.put(
  '/sort',
  verifyToken(),
  questionFavValidate.sortQuestionFavsValidate,
  questionFavController.sortQuestionFavs
)

/**
 * 检验题目是否被收藏
 */
router.post('/checkFav', verifyToken(), questionFavController.checkQuestionFav)

module.exports = router
